<<<<<<< .mine
package SM.Controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import SM.UI.Controls.DropDown;

/**
 * Servlet implementation class ReportIssue
 */

public class ReportIssue extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public ReportIssue() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// doGet is used to render HTML content
	
		/*Variable Declaration*/
		
		PrintWriter out = response.getWriter();
		SM.UI.Controls.DropDown ddBuildingCodes = new DropDown("building_code", 50);
		SM.UI.Controls.DropDown ddFlatCodes = new DropDown("flat_code", 50);
		SM.UI.Controls.DropDown ddIssueCategory = new DropDown("issue_category", 80);
		
		request.getRequestDispatcher("User/issues/report-1.html").include(request, response);
		
		String DisplayString = "<tr>" + 
				"<td class=\"col1\">Building Code</td>"+
				"<td class=\"col1\">"+
				// Building Codes -->
				"</td>"+
				"<td class=\"col2\">"+
				//<!-- Flat Codes -->
				"</td>"+
				"</tr>"+
		"</table>"+

"<br class=\"clearfix\"/>"+

"<table width=\"100%\" cellspacing=20>"+
	"<tr>"+
		"<td colspan=2 style=\"text-align:center;\" class=\"head-t\">"+
			"<div style=\"text-slign:center;\">Issue Information</div>"+
		"</td>"+
	"</tr>"+
	"<tr>"+
		"<td class=\"col1\">Issue Category</td>"+
		"<td class=\"col2\">"+
			//<!-- Issue Category -->
		"</td>"+
	"</tr>";
			
			
	out.println(DisplayString);
	
		request.getRequestDispatcher("User/issues/request-2.html").include(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// doPost is used to Accept request from page and Make Changes
		
		
	}

}
=======
package SM.Controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import SM.BusinessLogic.DBAccess;
import SM.BusinessLogic.DBService;
import SM.BusinessLogic.SessionVariables;


/**
 * Servlet implementation class ReportIssue
 */

public class ReportIssue extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public ReportIssue() {
        
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// doPost is used to Accept request from page and Make Changes
		
		PrintWriter out = response.getWriter();
		
		String user = SessionVariables.GetUser(request);
		String resp = request.getParameter("resp");
		String issue = request.getParameter("issue");
		String bCode = request.getParameter("b_code");
		String fCode = request.getParameter("f_code");

		if(user == null || resp == null || issue == null || bCode == null || fCode == null)
		{
			out.println("<span style='color:red;'>Error while reading parameters.. Please try logging in again</span>");
			return;
		}
		
		String insertQuery = "insert into Issues values(?,?,?,?,?,?,?,?)";
		
		synchronized(this)
		{
			
			Connection connection = null;
			PreparedStatement statement = null;
			try
			{
				String selectQuery = "select max(issue_id) from Issues";
				
				connection = DBAccess.MakeConnection();
			
				statement = connection.prepareStatement(selectQuery);
				
				ResultSet idSet = DBService.ExecuteStatement(connection, statement);
				
				int lastId = 0;
				
				if(idSet.next()) {
					lastId = idSet.getInt(1);
				}
				
				statement.close();
				
				statement = connection.prepareStatement(insertQuery);
				
				java.util.Date now = new java.util.Date();
				java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy HH:mm:ss");

				String curTime = sdf.format(now);
				
				statement.setInt(1, (lastId + 1)); //issue id auto-increment each time
				statement.setString(2, user); //issue by
				statement.setString(3, curTime); // time at which report submitted
				statement.setString(4, issue);
				statement.setString(5, resp);
				statement.setString(6, bCode); //get bldg and flat code from Profile . where username = user
				statement.setString(7, fCode);
				statement.setInt(8, 1); //0 status means closed
				
				statement.executeUpdate();
				
			}catch(SQLException SQLEx)
			{
				System.out.println("Exception in ReportIssue\nMessage : " + SQLEx.getMessage());
				return;
			}
			finally
			{
				DBAccess.CloseConnection(connection);
				DBAccess.CloseStatement(statement);
			}
		}
		
		out.println("<span style='color:green;'>Your request has been added</span>");
		
	}

}
>>>>>>> .r24
